// **************************************************************
// Com ++ Framework by the C++ World
// Please report defects: mailto:compp@cplusplusworld.com
// Please visit: http://www.cplusplusworld.com/socketlibrary.html
// **************************************************************

#include <iostream>
#include <string>
#include <cstdlib>

#include "ComPlusPlus/ComPlusPlus"
 
int main (int argc, char *argv [] ) {

  int port;
  std::string host = "127.0.0.1";

  if ( argc >= 2 )
	port = atoi ( argv [ 1 ] );
  else
	port = 5678 ;

  if ( argc >= 3 )
	host = argv [2 ];

  int tries =1;

  if ( argc == 4 )
	tries = atoi( argv [3 ]);

try {
  compp::AClnt C( host, port) ;

  std::string ret = "None";
  for ( int i=0; i < tries ; ++ i ) {
    ret = C.requestTransaction ( "Heya", true );
  }
  std::cout << "Received (cypered) " << ret << "\n";


  for ( int i=0; i < tries ; ++ i ) {
    ret = C.requestTransaction ( "Heya", false );
  }
  std::cout << "Received (plain)   " << ret << "\n";

} catch (  syspp::ComException  &e) {
   std::cout << "Exception " << e.what() << "\n";
}
  return 0;	
}
